from playwright.sync_api import sync_playwright
import time

with sync_playwright() as p:
    # 启动浏览器，显示窗口方便调试
    browser = p.chromium.launch(headless=False)
    page = browser.new_page()
    # 访问首页
    page.goto("http://10.59.9.14:7003/")
    # 页面刷新完成再进行下一步
    page.wait_for_load_state("networkidle")
    # 点击登录
    page.click('a[href="/home/login.html"]')
    # 等待登录页面加载完成
    page.wait_for_load_state("networkidle")
    # 输入用户名
    page.fill('input[name="username"]', "13811033962")
    # 输入密码
    page.fill('input[name="password"]', "123456")
    time.sleep(5)
    # 点击登录按钮
    page.click('a[class="finish-btn"]')
    time.sleep(5)
    # 关闭
    browser.close()


 